Skip to main content
Version: Mosquitto 2.8

Mosquitto Metrics Exporter

Premium

Pro Mosquitto provides a Prometheus exporter and a InfluxDB exporter which both expose the metrics available in the core broker and any metrics provided by other plugins.

Plugin configuration

Prometheus Metrics Exporter

To enable the Prometheus Metrics Exporter plugin it must be loaded into the broker with, by adding the following to your mosquitto.conf:

global_plugin /usr/lib/cedalo_metrics_prometheus.so

The plugin has some options which can be configured.

  • bind_address : by default, the exporter will listen on all available network interfaces. You can bind it to a specific address using this option. For example, plugin_opt_bind_address 192.0.2.1
  • port : by default, the exporter will listen on port 8000. You can use another port with this option. For example plugin_opt_port 8100
  • update_interval : metrics stored in the exporter are updated on a set interval, by default 15 seconds. It is important to match this to the scrape interval of your Prometheus setup. If you are using a 60 second scrape interval, then use plugin_opt_update_interval 60

A sample configuration could look like:

global_plugin /usr/lib/cedalo_metrics_prometheus.so
plugin_opt_update_interval 60
plugin_opt_bind_address 192.0.2.1
plugin_opt_port 8100

InfluxDB Metrics Exporter

To enable the InfluxDB Metrics Exporter plugin it must be loaded into the broker with, by adding the following to your mosquitto.conf:

global_plugin /usr/lib/cedalo_metrics_influxdb.so

The plugin has some options which can be configured.

  • hostname: The InfluxDB hostname to connect to. Required.

  • port: The network port to use to connect to InfluxDB. Optional, defaults to 8086.

  • username: The username to use when connecting to InfluxDB. Required.

  • password: The password to use when connecting to InfluxDB (i.e., the authorization token for the specified user). Required.

  • database: The InfluxDB database to send metrics to. Required.

  • use_tls: Set to true/false to use TLS encrypted connections. It is recommended to always use encrypted connections. Optional, defaults to false.

  • cafile: If you need to use a custom CA certificate for connecting to your InfluxDB instance, use this option to specify the file to use.

  • hostlabel: By default, the plugin will attempt to read the hostname of the instance where it is running, and set the host tag label to that value. This option allows you to specify a different label.

  • measurement: By default, the mosquitto measurement will be used for storing metrics. This option allows you to specify a different label.

  • update_interval : metrics stored in the exporter are published on a set interval, by default 15 seconds.

  • connect_timeout : Number of seconds to wait when connecting to InfluxDB, in case of failure. Optional, defaults to 10 seconds.

A sample configuration could look like:

global_plugin /usr/lib/cedalo_metrics_influxdb.so
plugin_opt_update_interval 60
plugin_opt_hostname influxdb.example.com
plugin_opt_port 8100
plugin_opt_hostlabel broker1
plugin_opt_database edge_data
plugin_opt_use_tls true
plugin_opt_username username
plugin_opt_password password

Optional configuration (applies to both exporters)

You may also consider turning off the $SYS updates from the broker:

sys_interval 0

Available metrics

labelmetric typedescription
mosq_broker_metric_sessionsGaugeCurrent client sessions (includes offline clients)
mosq_broker_metric_clients_offlineGaugeCurrent offline client count
mosq_broker_metric_clients_onlineGaugeCurrent online client count
mosq_broker_metric_clients_expiredCounterTotal clients expired due to keepalive
mosq_broker_metric_subscriptionsGaugeCurrent subscription count
mosq_broker_metric_shared_subscriptionsGaugeCurrent shared subscription count
mosq_broker_metric_retained_messagesGaugeCurrent retained message count
mosq_broker_metric_bytes_receivedCounterTotal bytes received
mosq_broker_metric_bytes_sentCounterTotal bytes sent
mosq_broker_metric_pub_bytes_receivedCounterTotal PUBLISH payload bytes received
mosq_broker_metric_pub_bytes_sentCounterTotal PUBLISH payload bytes sent
mosq_broker_metric_message_store_countGaugeCurrent stored message count
mosq_broker_metric_message_store_bytesGaugeCurrent stored message bytes
mosq_broker_metric_out_packetsGaugeCurrent queued outgoing packet count (includes offline clients)
mosq_broker_metric_out_packet_bytesGaugeCurrent queued outgoing packet bytes (includes offline clients)
mosq_broker_metric_socket_connectionsCounterTotal incoming connections
mosq_broker_metric_mqtt_packets_receivedCounterTotal MQTT packets received
mosq_broker_metric_mqtt_packets_sentCounterTotal MQTT packets sent
mosq_broker_metric_mqtt_connect_receivedCounterMQTT CONNECT received
mosq_broker_metric_mqtt_connect_sentCounterMQTT CONNECT sent
mosq_broker_metric_mqtt_connack_receivedCounterMQTT CONNACK received
mosq_broker_metric_mqtt_connack_sentCounterMQTT CONNACK sent
mosq_broker_metric_mqtt_publish_droppedCounterMQTT PUBLISH dropped
mosq_broker_metric_mqtt_publish_receivedCounterMQTT PUBLISH received
mosq_broker_metric_mqtt_publish_sentCounterMQTT PUBLISH sent
mosq_broker_metric_mqtt_puback_receivedCounterMQTT PUBACK received
mosq_broker_metric_mqtt_puback_sentCounterMQTT PUBACK sent
mosq_broker_metric_mqtt_pubrec_receivedCounterMQTT PUBREC received
mosq_broker_metric_mqtt_pubrec_sentCounterMQTT PUBREC sent
mosq_broker_metric_mqtt_pubrel_receivedCounterMQTT PUBREL received
mosq_broker_metric_mqtt_pubrel_sentCounterMQTT PUBREL sent
mosq_broker_metric_mqtt_pubcomp_receivedCounterMQTT PUBCOMP received
mosq_broker_metric_mqtt_pubcomp_sentCounterMQTT PUBCOMP sent
mosq_broker_metric_mqtt_subscribe_receivedCounterMQTT SUBSCRIBE received
mosq_broker_metric_mqtt_subscribe_sentCounterMQTT SUBSCRIBE sent
mosq_broker_metric_mqtt_suback_receivedCounterMQTT SUBACK received
mosq_broker_metric_mqtt_suback_sentCounterMQTT SUBACK sent
mosq_broker_metric_mqtt_unsubscribe_receivedCounterMQTT UNSUBSCRIBE received
mosq_broker_metric_mqtt_unsubscribe_sentCounterMQTT UNSUBSCRIBE sent
mosq_broker_metric_mqtt_unsuback_receivedCounterMQTT UNSUBACK received
mosq_broker_metric_mqtt_unsuback_sentCounterMQTT UNSUBACK sent
mosq_broker_metric_mqtt_pingreq_receivedCounterMQTT PINGREQ received
mosq_broker_metric_mqtt_pingreq_sentCounterMQTT PINGREQ sent
mosq_broker_metric_mqtt_pingresp_receivedCounterMQTT PINGRESP received
mosq_broker_metric_mqtt_pingresp_sentCounterMQTT PINGRESP sent
mosq_broker_metric_mqtt_disconnect_receivedCounterMQTT DISCONNECT received
mosq_broker_metric_mqtt_disconnect_sentCounterMQTT DISCONNECT sent
mosq_broker_metric_mqtt_auth_receivedCounterMQTT AUTH received
mosq_broker_metric_mqtt_auth_sentCounterMQTT AUTH sent
mosq_broker_metric_basic_auth_successCounterSuccessful username/password authentication attempts
mosq_broker_metric_basic_auth_failCounterFailed username/password authentication attempts
mosq_broker_metric_basic_auth_errorCounterErrored username/password authentication attempts
mosq_broker_metric_extended_auth_successCounterSuccessful extended authentication attempts
mosq_broker_metric_extended_auth_failCounterFailed extended authentication attempts
mosq_broker_metric_extended_auth_errorCounterErrored extended authentication attempts